﻿package com.dogcatfishdish.depthdisplay 
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	/**
	 * ...
	 * @author bb
	 */
	public class DepthItem extends Sprite
	{
		protected var _z:Number = 0;
		protected var _item:DisplayObject;

		public var fov:Number = 250;
		
		public function DepthItem(item:DisplayObject) 
		{
			_item = item;
			addChild(_item);
		}

		public function get z():Number {
			return _z;
		}
		
		public function set z(value:Number):void {
			_z = value;
		
			_item.scaleY = _item.scaleX = getCurrentScale();
		}
		
		protected function getCurrentScale():Number {
			return fov / (-_z + fov);
		}
	}

}